package com.school.empsys.task;

import com.school.empsys.mapper.EmpAttendanceMapper;
import com.school.empsys.model.EmpAttendance;
import com.school.empsys.service.EmpAttendanceService;
import com.school.empsys.service.EmpContractService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 系统定时器
 */
@Component
public class SystemTask {

    private static Logger logger = LoggerFactory.getLogger(SystemTask.class);

    @Autowired
    EmpContractService empContractService;
    @Autowired
    EmpAttendanceService empAttendanceService;

    /**
     * 员工合同到期自动作废，作废后还可以登录一个月
     */
    @Scheduled(cron = "${empcontract.expirt.corn}")
    public synchronized void expirtEmpContract() {
        logger.info("expirtEmpContract开始");
        empContractService.expirtEmpContract();
        logger.info("expirtEmpContract结束");
    }

    /**
     * 员工合同到期自动作废，作废后还可以登录一个月
     */
    @Scheduled(cron = "${daily.attendance.corn}")
    public synchronized void dailyAttendance() {
        logger.info("dailyAttendance");
        empAttendanceService.dailyAttendance();
        logger.info("dailyAttendance");
    }

}
